import base64
from typing import List

import shortuuid
from peewee import JOIN

from afast_core.core_libs.captcha.cilent import generate_captcha
from afast_core.core_tools.jwt_helper import SimpleAuth
from infirmary_admin_src.infirmary_common.infirmary_controller import IAsyncSessionBaseController, IBaseController
from infirmary_admin_src.infirmary_common.infirmary_controller.rest_controller_with_depends import \
    RestControllerWithDepends
from fastapi import Request, Depends
from afast_core.core_tools import json_helper
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.infirmary.businesses.schemas import SchemaBase


class XParam(SchemaBase):
    '''
    账号密码登录参数
    '''


class IController(IBaseController):
    '''
    定制相关约束检测函数逻辑步序
    '''

    def __init__(self, *, request: Request,
                 ):
        super().__init__(request=request)
        # 入参参数


@RestControllerWithDepends()
class AuthRouteController(IController):

    def business_login(self):
        pass
        # 生成验证码
        random_str, image_data = generate_captcha(width=80, height=25)
        base64_data = str(base64.b64encode(image_data), "utf-8")  # 使用base64进行加密
        # request.session["session_code"] = random_str.lower()
        return [{
            "path": "system",
            "meta": {
                "locale": "系统管理",
                "icon": "settings",
                "hideInMenu": False,
                "ignoreCache": True,
                "requiresAuth": True
            },
            "children": [{
                "path": "/system/user",
                "name": "User",
                "component": "/system/user/index",
                "meta": {
                    "locale": "用户管理",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }, {
                "path": "/system/role",
                "name": "Role",
                "component": "system/role/index",
                "meta": {
                    "locale": "角色管理",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }, {
                "path": "/system/menu",
                "name": "Menu",
                "component": "system/menu/index",
                "meta": {
                    "locale": "菜单管理",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }, {
                "path": "/system/dept",
                "name": "Dept",
                "component": "system/dept/index",
                "meta": {
                    "locale": "部门管理",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }]
        }, {
            "path": "monitor",
            "meta": {
                "locale": "系统监控",
                "icon": "computer",
                "hideInMenu": False,
                "ignoreCache": True,
                "requiresAuth": True
            },
            "children": [{
                "path": "/monitor/online",
                "name": "OnlineUser",
                "component": "monitor/online/index",
                "meta": {
                    "locale": "在线用户",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }, {
                "path": "/monitor/log/login",
                "name": "LoginLog",
                "component": "monitor/log/login/index",
                "meta": {
                    "locale": "登录日志",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }, {
                "path": "/monitor/log/operation",
                "name": "OperationLog",
                "component": "monitor/log/operation/index",
                "meta": {
                    "locale": "操作日志",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }, {
                "path": "/monitor/log/system",
                "name": "SystemLog",
                "component": "monitor/log/system/index",
                "meta": {
                    "locale": "系统日志",
                    "icon": None,
                    "hideInMenu": False,
                    "ignoreCache": True,
                    "requiresAuth": True
                }
            }]
        }, {
            "path": "https://arco.design/vue/docs/start",
            "meta": {
                "locale": "Arco Design Vue",
                "icon": "link",
                "hideInMenu": False,
                "ignoreCache": True,
                "requiresAuth": True
            }
        }, {
            "path": "https://github.com/Charles7c/continew-admin",
            "meta": {
                "locale": "GitHub",
                "icon": "github",
                "hideInMenu": False,
                "ignoreCache": True,
                "requiresAuth": True
            }
        }]
